package arsmodelller.factories;

import org.eclipse.gef.requests.CreationFactory;

import arsmodeller.model.BusinessProcess;
import arsmodeller.model.Employee;
import arsmodeller.model.Service;

public class NodeCreationFactory implements CreationFactory {
	private Class<?> template;

	public NodeCreationFactory(Class<?> t) {
		this.template = t;
	}

	@Override
	public Object getNewObject() {
		if (template == null)
			return null;
		if (template == Service.class) {
			Service srv = new Service();
			srv.setName("Untitled");
			return srv;
		} else if (template == Employee.class) {
			Employee emp = new Employee();
			emp.setPrenom("Untitled");
			emp.setName("Employee ");
			return emp;
		} else if (template == BusinessProcess.class) {
			BusinessProcess bpr = new BusinessProcess();
			bpr.setName("Untitled Business Process");
			bpr.setJavaCode("");
			bpr.setText("No Text");
			return bpr;
		}

		return null;

	}

	@Override
	public Object getObjectType() {
		return template;
	}

}
